from lxml import etree
import requests
url="https://www.ryjiaoyu.com/book"
headers={
       "User-Agent":"Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Mobile Safari/537.36 Edg/111.0.1661.54"
}
responese=requests.get(url,headers=headers)
responese.encoding="utf-8"
#转为html树结构
html=etree.HTML(responese.text)
#通过xpath来寻找/表示找其中的子代
aa=html.xpath('//div[@class="book-info"]/h4/a/text()')
print(aa)
#result=etree.tostring(html.xpath('//div[@class="book-info"]')[0])

